package org.company.earth.utils;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringUtils {
	
	private ApplicationContext context = null;
	
	private static SpringUtils instance = null;
	
	private SpringUtils() {
		context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
	}
	
	public static SpringUtils getInstance() {
		if(instance == null)
			instance = new SpringUtils();
		return instance;
	}
	
	public Object getBean(String name) {
		return context.getBean(name);
	}
	
	public <T> T getBean(String name,Class<T> clazz) {
		return context.getBean(name, clazz);
	}
}
